﻿using banjimange.Data;
using banjimange.Models;
using Microsoft.AspNetCore.Mvc;
using System;

namespace banjimange.Controllers
{
    public class ManageController : Controller
    {
        private readonly ILogger<HomeController> _logger;
        private readonly DataContext _context;
        public ManageController(ILogger<HomeController> logger, DataContext context)
        {
            _logger = logger;
            _context = context;
        }
        [HttpGet]
        public IActionResult UserManage()
        {
           var UserName = HttpContext.Session.GetString("UserName");
            var user = _context.Users.FirstOrDefault(m => m.UserName == UserName);
            return View(user);
        }
        public IActionResult StudentManage()
        {
            return View();
        }
        public IActionResult Create()
        {
            return View();
        }
        [HttpPost]
        public IActionResult SubmitForm(ClassModel jsonData)
        {
            if (ModelState.IsValid)
            {
                // 在这里处理模型数据，例如保存到数据库或发送电子邮件等操作。  
                // ...  
                return RedirectToAction("Index"); // 重定向到首页或其他页面。  
            }
            return View(); // 返回表单视图并显示错误信息。  
        }
    }
}
